package com.kiln.juxingqs.ui.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import client.global.commlib.network.data.JsonResult
import client.global.commlib.network.data.Ret
import com.kiln.juxingqs.api.bean.GoodsOrder
import com.kiln.juxingqs.api.bean.WdthRet
import com.kiln.juxingqs.ui.viewmodel.MiddleVm


class WdthViewModel(app: Application) : MiddleVm(app) {
    val isShowing = MutableLiveData<Boolean>(false)
    val searchVal = MutableLiveData<String>("")

    val isOneLoading = MutableLiveData<Boolean>(false)
    val pageOne = MutableLiveData<Int>(0)
    val callOne = MutableLiveData<JsonResult<WdthRet>>()
    val qrshCall = MutableLiveData<JsonResult<Ret>>()

    fun holdOne() {
        if (isOneLoading.value!!)
            return
        hold({
            server.deal_deliver_record(pageOne.value!!)
        }, {
            isOneLoading.value = true
            pageOne.value = pageOne.value!! + 1
        }, {
            callOne.value = it
        }, complete = {
            isOneLoading.value = false
        })
    }

    fun confirm_order(b: WdthRet.Deliver) {
        hold({
            server.confirm_order("${b.id}")
        }, {
            isShowing.value = true
        }, {
            qrshCall.value = it
        }, complete = {
            isShowing.value = false
        })
    }

}